<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../resources/main.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="estilo.css" />
        <p:separator />
        <div class="pagina">
            Lista de Pacientes
        </div>
        <p:separator />
        <p:growl />
        <h:form id="frmPesqHospede">
            <fieldset>
                <legend style="font-size: 18px; color: #D20005">Pesquisar Hospedes</legend>
                <h:panelGrid columns="3">                   
                    <h:outputLabel value="Nome.:" styleClass="lb" style="float: left;"/>
                    <h:inputText value="#{mbHospede.pesquisa}" onkeyup="this.value = this.value.toUpperCase()" 
                                 styleClass="tx" style="color: #D20005;" size="40">                
                    </h:inputText>
                    <p:commandLink action="#{mbHospede.pesquisarHospede}" update=":tbHosp" title="Click para realizar a pesquisa" ajax="false">
                        <h:graphicImage library="img" name="lupa2.bmp" />
                    </p:commandLink>
                </h:panelGrid>
            </fieldset>
        </h:form>
        <h:form id="tbHosp">           
            <p:dataTable value="#{mbHospede.hospedes}" var="h">              
                <p:column headerText="Cod" style="text-align: center; font-size: 12px;">
                    <h:outputText value="#{h.idHospede}" styleClass="txt" />
                </p:column>
                <p:column headerText="Nome" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{h.nome}" styleClass="txt" />
                </p:column>
                <p:column headerText="Sexo" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{h.sexo}" styleClass="txt" />
                </p:column>
                <p:column headerText="CPF" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{h.cpf}" styleClass="txt" />
                </p:column>
                <p:column headerText="DT. Nasc" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{h.nascimento}" styleClass="txt">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:outputText>
                </p:column>
                <p:column headerText="Endereço" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{h.endereco}" styleClass="txt" />
                </p:column>
                <p:column headerText="Município" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{h.cidade.cidade}" styleClass="txt" />
                </p:column>               
                <p:column headerText="Op" style="text-align: left; font-size: 12px;">
                    <h:commandLink value="Alterar" action="#{mbHospede.alterarHospede}" onclick="alert('#{h.idHospede}  #{h.nome}')" styleClass="txt">
                        <f:setPropertyActionListener target="#{mbHospede.codigoHospede}" value="#{h.idHospede}" />
                    </h:commandLink>
                </p:column>               
            </p:dataTable>
        </h:form>
        <p:separator />
        <h:form>
            <h:panelGrid columns="3">
                <h:outputLabel for="codigo" value="Codigo do hospede.:" styleClass="lb" />
                <h:inputText id="codigo" value="#{mbHospede.codigoHospede}" styleClass="tx" size="20" 
                             title="Digite o codigo do hospede que deseja fazer alteração" converterMessage="Digite somente números">
                    <f:convertNumber type="number" />
                </h:inputText>
                <p:commandLink value="Carregar" action="#{mbHospede.alterarHospede}" 
                               ajax="false" title="Click para carrega o hospede no formulario para alteração" />
            </h:panelGrid>
        </h:form>
    </ui:define>

</ui:composition>
